﻿/**********************************************************************
*创建人：蔡水明
*创建时间：2018/3/9 13:06:24
*说明：<Function>
/**********************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Utilities
{
    /// <summary>
    /// 硬件信息
    /// </summary>
    public class HardWareHelper
    {
        /// <summary>
        /// 获取最大磁盘剩余空间的硬盘
        /// </summary>
        /// <returns></returns>
        public static string GetMaxkFreeSpace()
        {
            string driverName = string.Empty;
            long MaxSpace = 0;
            System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();
            foreach (System.IO.DriveInfo drive in drives)
            {
                if (drive.DriveType == System.IO.DriveType.CDRom) continue;
                if (drive.DriveType == System.IO.DriveType.Network) continue;
                if (drive.DriveType == System.IO.DriveType.Removable) continue;
                if (drive.TotalFreeSpace > MaxSpace)
                {
                    MaxSpace = drive.TotalFreeSpace;
                    driverName = drive.Name;
                }
            }
            return driverName;
        }
    }
}
